package com.shujia.core

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Demo06MapValues {
  def main(args: Array[String]): Unit = {
    val conf: SparkConf = new SparkConf()
    conf.setAppName("Demo06MapValues")
    conf.setMaster("local")

    val sc: SparkContext = new SparkContext(conf)

    val kvRDD: RDD[(String, Int)] = sc.parallelize(List[(String, Int)](("k1", 1), ("k2", 2), ("k3", 3)))

    // 对K V格式的RDD的V进行依次处理
    kvRDD.mapValues(i => i * i).foreach(println)
  }

}
